 <template>
   <Card :shadow="shadow">
      <div class="card-name">
        <div class="name width1">消息详情</div>
      </div>
      <div class="content-con">
        <i-form ref="formValidate" :model="formValidate" label-position="right" :label-width="110" class="news-item">
          <Form-item label="消息标题" prop="newtitle">
            <i-input v-model="formValidate.newtitle" size="large" placeholder="输入消息标题"></i-input>
          </Form-item>
          <Form-item label="状态" prop="status">
            <Radio-group v-model="formValidate.status" size="large">
              <Radio label="0">
                  <span>显示</span>
              </Radio>
              <Radio label="1">
                  <span>隐藏</span>
              </Radio>
            </Radio-group>
          </Form-item>
          <Form-item label="消息内容" prop="newcontent">
            <editor ref="editor" v-model="formValidate.newcontent" @on-change="handleChange"/>
            <!-- <Button @click="changeContent">修改编辑器内容</Button> -->
          </Form-item>
          <Form-item>
            <i-button @click="handleSubmit()" class="save" size="large">保存</i-button>
            <i-button class="save" size="large" @click="btnClick1">返回</i-button>
          </Form-item>
        </i-form>
      </div>
   </Card>

 </template>
 <script>
 import { mapMutations } from 'vuex'
 import Editor from '_c/editor';
 export default {
   name: 'news-edit',
   components: {
     Editor
   },
   props:{
     shadow: {
       type: Boolean,
       default: false
     }
   },
   data() {
     return {
       value: '啦啦啦',
       status: '显示',
       content: '哈哈哈哈哈哈哈哈',
       formValidate:{
         newtitle: '啦啦啦',
         status: '0',
         newcontent: ''
       }
     };
   },
   methods: {
     //表单验证
     handleSubmit () {
       this.$refs['formValidate'].validate((valid) =>{
         if (valid) {
           this.$Message.success('提交成功!');
         } else {
           this.$Message.error('表单验证失败!');
         }
       })
     },
     //富文本
     handleChange (html, text) {
       console.log(html, text)
     },
     // changeContent () {
     //   this.$refs.editor.setHtml('<p>powered by wangeditor</p>')
     // }

     //关闭标签页
     ...mapMutations([
       'closeTag'
     ]),
     close () {
       console.log(this.$route.params.row)
       this.closeTag({
         name: 'news-edit',
         // params: {
         //   row: this.$route.params.row
         // }
       })
     },
     // 返回按钮
     btnClick1 () {
       this.close()
     }
   }
 };
 </script>
 <style lang="less">
   .news-item .ivu-form-item-label {
     font-size: 14px;
   }
 </style>
